<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<div class="user-applications-container">
    <div class="user-applications-content" fxFlex="70">
      <ngx-datatable *ngIf="devices.length > 0" class="material"
                     [columnMode]="'flex'"
                     [sortType]="'multi'"
                     [headerHeight]="40"
                     [footerHeight]="40"
                     [rowHeight]="50"
                     [rows]='devices'>
        <ngx-datatable-column name="Device Id" [flexGrow]="2">
          <ng-template let-row="row" ngx-datatable-cell-template>
            {{ row.deviceId }}
          </ng-template>
        </ngx-datatable-column>
        <ngx-datatable-column name="Type" [flexGrow]="1">
          <ng-template let-row="row" ngx-datatable-cell-template>
            {{ row.type }}
          </ng-template>
        </ngx-datatable-column>
        <ngx-datatable-column name="Client" [flexGrow]="1">
          <ng-template let-row="row" ngx-datatable-cell-template>
            {{ getApplicationName(row.client) }}
          </ng-template>
        </ngx-datatable-column>
        <ngx-datatable-column name="Device Identifier" [flexGrow]="1">
          <ng-template let-row="row" ngx-datatable-cell-template>
            {{ getDeviceIdentifierName(row.deviceIdentifierId) }}
          </ng-template>
        </ngx-datatable-column>
        <ngx-datatable-column name="Created At" [flexGrow]="1">
          <ng-template let-row="row" ngx-datatable-cell-template>
            {{row.createdAt | humanDate}}
          </ng-template>
        </ngx-datatable-column>
        <ngx-datatable-column name="Expires at" [flexGrow]="1">
          <ng-template let-row="row" ngx-datatable-cell-template>
            {{row.expiresAt | humanDate}}
          </ng-template>
        </ngx-datatable-column>
        <ngx-datatable-column *ngIf="canDelete" [flexGrow]="1">
          <ng-template let-row="row" ngx-datatable-cell-template>
            <div fxLayout="row" class="gv-table-cell-actions">
              <button mat-icon-button (click)="remove($event, row)"><mat-icon style="color: #f44336;" matTooltip="Remove device">highlight_off</mat-icon></button>
            </div>
          </ng-template>
        </ngx-datatable-column>
      </ngx-datatable>
      <app-emptystate *ngIf="devices.length == 0"
                      [message]="'No device registered'"
                      [subMessage]="'No data to display'"
                      [icon]="'devices'"></app-emptystate>
    </div>
    <div class="gv-page-description" fxFlex>
      <h3>Devices</h3>
      <div class="gv-page-description-content">
        <p>
          Devices the user logged in with per application and per device identifier
        </p>
      </div>
    </div>
</div>

